/**
 *
 */
package asa;

/** Used to generate code using a PrintWriter object.
 *
 * @author José
 *
 */

import java.io.*;

public class PW implements PWInterface {

	@Override
	public void add() {
		currentIndent += step;
	}

	@Override
	public void sub() {
		currentIndent -= step;
	}

	public void set(PrintWriter out) {
		this.out = out;
		currentIndent = 0;
	}

	@Override
	public void set(int indent) {
		currentIndent = indent;
	}

	@Override
	public void println() {
		out.println();
	}

	@Override
	public void print(char[] s) {
		out.print(s);
	}

	@Override
	public void println(char[] s) {
		out.println(s);
	}

	@Override
	public void print(String s) {
		out.print(s);
	}

	@Override
	public void println(String s) {
		out.println(s);
	}

	@Override
	public void printIdent(String s) {
		out.print(space.substring(0, currentIndent));
		out.print(s);
	}

	@Override
	public void printlnIdent(String s) {
		out.print(space.substring(0, currentIndent));
		out.println(s);
	}

	public PrintWriter getPrintWriter() {
		return out;
	}

	int currentIndent = 0;

	private int step = 4;
	private PrintWriter out;

	static final private String space = "                                                                                                        ";

}
